<?php

namespace App\Http\Requests;

class Manage extends Base
{

    public function rules()
    {
        $id = $this->get('id');
        $rules = [
            //unique:表名,字段名,排除ID,主键字段,条件字段,条件,
            'username' => 'required|unique:admins,username,'.$id,
            'nickname' => 'required',
            'role_id'  => 'required',
            'password' => 'sometimes|min:6',
        ];
        return $rules;

    }

    public function messages()
    {
        return [
            'username.required' => '请填写管理员账号',
            'username.unique'   => '管理员账号已存在',
            'role_id.required'  => '请选择管理员角色',
            'nickname.required' => '请填写管理员账号昵称',
            'password.min'      => '账号密码不能低于6位数',
        ];
    }
}
